package com.imooc.order.util;

import java.util.Random;
import java.util.UUID;

/**
 *
 * @author steve
 * @date 2020/5/8 10:57
 */
public class KeyUtil {

    /**
     * 生成唯一主键id
     * @return
     */
    public static String genUniqueKey() {
        //new Random().nextInt(900000)+100000：生成6位随机数
        return System.currentTimeMillis() + String.valueOf(new Random().nextInt(900000)+100000);
        //return UUID.randomUUID().toString().replaceAll("-", "");
    }


    public static void main(String[] args) {
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
        System.out.println(System.currentTimeMillis() + String.valueOf(new Random().nextInt(900000)+100000));
        System.out.println(uuid);
    }
}
